package com.biz.primus.account.feign;

import com.biz.primus.base.exception.BizCheckedException;
import com.biz.primus.model.sso.auth.vo.MenusRegisterReqVO;
import com.biz.primus.model.sso.auth.vo.UserAuthoritiesResVO;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * Created by younger on 17/11/3.
 */
@FeignClient(qualifier = "authorityFeignClient", name = "service-sso-auth", fallback = AuthorityDegradedFeignClient.class)
public interface AuthorityFeignClient {
    /**
     * 查询用户权限菜单
     */
    @PostMapping("soa/authorityService/getUserAuthorities")
    public UserAuthoritiesResVO getUserAuthorities(@RequestParam(name = "userUnionId") String userUnionId);

    /**
     * 设置服务器模块上报菜单及权限
     */
    @PostMapping("soa/authorityService/authorityRegister")
    void authorityRegister(@RequestBody MenusRegisterReqVO reqVO);

    /**
     * 获取用户在当前服务中可访问的菜单及拥有的权限
     * @param userUnionId 统一用户id
     */
    @GetMapping("soa/authorityService/listUserMenusAndGrantedAuthorities")
    UserAuthoritiesResVO listUserMenusAndGrantedAuthorities(@RequestParam(name = "userUnionId") String userUnionId) throws BizCheckedException;
}
